!
Subroutine rttov_q2v (&
       & h2o_unit,  &! in
       & h2o,       &! in
       & gaz_id,    &! in
       & q_gaz,     &! in
       & v_gaz     ) ! inout
  !
  ! Description:
  !   Conversion of specific concentration to volume mixing ratio gases.
  !   Gases are defined by the "gas_id_xxx" codes in the rttov_const module
  !   Method use an equivalent molecular weight of wet air
  !
  ! Copyright:
  !
  !    This software was developed within the context of
  !    the EUMETSAT Satellite Application Facility on
  !    Numerical Weather Prediction (NWP SAF), under the
  !    Cooperation Agreement dated 25 November 1998, between
  !    EUMETSAT and the Met Office, UK, by one or more partners
  !    within the NWP SAF. The partners in the NWP SAF are
  !    the Met Office, ECMWF, KNMI and MeteoFrance.
  !
  !    Copyright 2002, EUMETSAT, All Rights Reserved.
  !
  !
  !
  ! Current Code Owner: SAF NWP
  !
  ! History:
  ! Version    Date      Comment
  !  1.0    27/01/2003  Original code. (P. Brunel)
  !  1.1    13/02/2003  Remove capability of array of gases (P. Brunel)
  !
  ! Code Description:
  !   FORTRAN 90, following AAPP standards
  !
  ! Declarations
  !
  ! Global variables:
  ! Modules used:
  ! Imported Parameters:
  


!INTF_OFF
Use iasing_osse, Only : &
    JPI4, &
    JPR4, &
    JPR8, &
    mair,&
    mh2o,&
    mo3,&
    mco2,&
    mn2o,&
    mco,&
    mch4,&
    mso2,&
    gas_id_mixed,&
    gas_id_watervapour,&
    gas_id_ozone,&
    gas_id_wvcont,&
    gas_id_co2,&
    gas_id_n2o,&
    gas_id_co,&
    gas_id_ch4,&
    gas_id_so2,&
    gas_unit_specconc,&
    gas_unit_ppmv
!INTF_ON

  Implicit None

  ! Subroutine arguments
  !   Scalar arguments with intent(in):
  Integer(Kind=JPI4) , Intent (in) :: h2o_unit ! Water vapour input unit
                                    ! 1 = specific concent. (kg/kg)
                                    ! 2 = volume mixing ratio (ppmv)
                                    ! (see gaz id codes in module rttov_const)
  Real(Kind=JPR8)    , Intent (in) :: h2o      ! Water Vapour content in unit h2o_unit

  Integer(Kind=JPI4) , Intent (in) :: gaz_id   ! Gaz identification number
                                    ! (see gaz id codes in module rttov_const)
  Real(Kind=JPR8)    , Intent (in)   :: q_gaz  ! specific concentration for gaz (kg/kg)
  Real(Kind=JPR8)    , Intent (inout):: v_gaz  ! volume mixing ratio for gaz (ppmv)


!INTF_END

  ! Local parameter
  Real(Kind=JPR8), Parameter :: eps = mh2o / mair



  ! Local variables
  Real(Kind=JPR8) :: Mwet  ! equivalent molecular weight of wet air (g)
  Real(Kind=JPR8) :: v_h2o ! volume mixing ratio for Water Vapour (v/v)

  !- End of header --------------------------------------------------------

  ! Calculate volume mixing ratio (no unit: v/v) for Water Vapour
  If( h2o_unit == gas_unit_specconc ) then
     v_h2o = h2o / (eps * (1-h2o) + h2o)
  Else If( h2o_unit == gas_unit_ppmv ) then
     v_h2o = h2o * 1.e-06_JPR8
  Else
     v_h2o = 0._JPR8
  End If

  ! Humid air molar mass
  Mwet = (1 - v_h2o)*Mair + v_h2o*Mh2o

  ! Calculate volume mixing ratio for gaz (ppmv)
  Select Case( gaz_id )
  Case( gas_id_mixed )
     ! keep same value for Mixed gases
     v_gaz = q_gaz

  Case( gas_id_watervapour )
     v_gaz = q_gaz * Mwet / Mh2o * 1.e+06_JPR8
     !v_gaz = q_gaz * 1.60771704e+6

  Case( gas_id_ozone )
     v_gaz = q_gaz * Mwet / Mo3  * 1.e+06_JPR8
     !v_gaz = q_gaz * 6.03504e+5

  Case( gas_id_wvcont )
     v_gaz = q_gaz * Mwet / Mh2o * 1.e+06_JPR8

  Case( gas_id_co2 )
     v_gaz = q_gaz * Mwet / Mco2 * 1.e+06_JPR8

  Case( gas_id_n2o )
     v_gaz = q_gaz * Mwet / Mn2o * 1.e+06_JPR8

  Case( gas_id_co )
     v_gaz = q_gaz * Mwet / Mco  * 1.e+06_JPR8

  Case( gas_id_ch4 )
     v_gaz = q_gaz * Mwet / Mch4 * 1.e+06_JPR8

  Case( gas_id_so2 )
     v_gaz = q_gaz * Mwet / Mso2 * 1.e+06_JPR8

  Case Default
     v_gaz = 0._JPR8

  End Select




End Subroutine rttov_q2v
